package com.glodon.paas.monitor.server.biz.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.glodon.paas.job.exception.JsonException;
import com.glodon.paas.job.util.JsonUtil;

public class MonitorStatusEntity implements Serializable {

	private static final long	serialVersionUID	= 8111981484319565867L;

	// 主键
	private String				id;

	// 任务命令
	private String				cmd;

	// 监控类型
	private String				monitorType;

	// 监控标识
	private String				traceId;

	// 监控序号
	private Integer				traceIndex;

	// 任务主键
	private String				taskId;

	// 创建时间
	private Date				createdTime;

	// 更新时间
	private Date				updatedTime;

	// 监控明细
	private Map<String, Object>	values				= new HashMap<String, Object>();

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCmd() {
		return cmd;
	}

	public void setCmd(String cmd) {
		this.cmd = cmd;
	}



	public String getMonitorType() {
		return monitorType;
	}

	public void setMonitorType(String monitorType) {
		this.monitorType = monitorType;
	}

	public String getTraceId() {
		return traceId;
	}

	public void setTraceId(String traceId) {
		this.traceId = traceId;
	}

	public Integer getTraceIndex() {
		return traceIndex;
	}

	public void setTraceIndex(Integer traceIndex) {
		this.traceIndex = traceIndex;
	}

	public String getTaskId() {
		return taskId;
	}

	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}

	public Date getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	public Date getUpdatedTime() {
		return updatedTime;
	}

	public void setUpdatedTime(Date updatedTime) {
		this.updatedTime = updatedTime;
	}

	public Map<String, Object> getValues() {
		return values;
	}

	public void setValues(Map<String, Object> values) {
		this.values = values;
	}

	public String getJson() {
		return JsonUtil.mapToJson(values);
	}

	@SuppressWarnings("unchecked")
	public void setJson(String json) throws JsonException {
		values = JsonUtil.jsonToMap(json);
	}

	public String getValue(String key) {
		Object value = values.get(key);
		return value == null ? null : value.toString();
	}

	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

}
